﻿using System;
using System.Windows.Forms;

namespace Test30.Tools.DataView
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            viewControl11.SetMap();
            ViewCount();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (viewControl11.MapHandler != null)
            {
                viewControl11.Next();
                ViewCount();
            }
        }

        private void ViewCount()
        {
            viewControl11.MapHandler.GeneratorCount();
            floors.Text = Floors + viewControl11.MapHandler.Floors;
            walls.Text = Walls + viewControl11.MapHandler.Walls;
        }

        private void Stats_Click(object sender, EventArgs e)
        {
            if (viewControl11.MapHandler == null)
                viewControl11.SetMap();

            for (int i = 0; i < Count; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    viewControl11.MapHandler.MakeCaverns();
                }
                viewControl11.MapHandler.GeneratorCount();
                _fMin = Math.Min(_fMin, viewControl11.MapHandler.Floors);
                _fMax = Math.Max(_fMax, viewControl11.MapHandler.Floors);
                _wMin = Math.Min(_wMin, viewControl11.MapHandler.Walls);
                _wMax = Math.Max(_wMax, viewControl11.MapHandler.Walls);
            }
            floorMin.Text = $"{_fMin / 448.0f}   {FMin} {_fMin}";
            floorMax.Text = $"{_fMax / 448.0f}   {FMax} {_fMax}";
            wallMin.Text = $"{_wMin / 448.0f}   {WMin} {_wMin}";
            wallMax.Text = $"{_wMax / 448.0f}   {WMax} {_wMax}";

        }

        private void MakeStair_Click(object sender, EventArgs e)
        {
            viewControl11.MapHandler.MakeStairs();
            viewControl11.Refresh();
        }

        private const string Floors = "Floors:";

        private const string Walls = "Walls:";

        private const string FMin = "FMin:";

        private const string FMax = "FMax:";

        private const string WMin = "WMin:";

        private const string WMax = "WMax:";

        private int _fMin = 1000;

        private int _fMax ;

        private int _wMin = 1000;

        private int _wMax ;

        private const int Count = 1000;
    }
}
